<script type="text/javascript" >
var menu =
[

//These need to be modified so that it scrolls to the proper place on the page,


	{"name": "Clients", "href": "?page=clients", "file": "clients",
		"submenu": [
					{"name":"File System",		"href": "?page=clients"},
					{"name":"Client Access",	"href": "?page=clients"}
					]
	},




	{"name": "Contact", "href": "?page=contact", "file": "contact",
		"submenu": [
					{"name":"css",			"href": "?page=contact"},
					{"name":"Telephone",	"href": "?page=contact"},
					{"name":"Postal",		"href": "?page=contact"},
					{"name":"Map",			"href": "?page=contact"}
					]
	},




	{"name": "Portfolio", "href": "?page=portfolio", "file": "portfolio",
		"submenu": [
					{"name":"Desktop Application",	"href": "?page=portfolio"},
					{"name":"Web Development",		"href": "?page=portfolio"},
					{"name":"PDA Applications",		"href": "?page=portfolio"},
					]
	},




	{"name": "Profile", "href": "?page=profile", "file": "profile",
		"submenu": [
					{"name":"History",	"href": "?page=profile"}
					]
	},



	{"name": "Services", "href": "?page=services", "file": "services",
		"submenu": [
					{"name":"Desktop Application",	"href": "?page=services"},
					{"name":"PDA Applications",		"href": "?page=services"},
					{"name":"Web Developement",		"href": "?page=services"},
					{"name":"Graphic Design",		"href": "?page=services"},
					{"name":"Web Hosting",			"href": "?page=services"}
					]
	},




	{"name": "Web Hosting", "href": "?page=webhosting", "file": "webhosting",
		"submenu": [
					{"name":"Host Accounts",	"href": "?page=webhosting"},
					{"name":"Services",			"href": "?section=webhosting&page=webservice"},
					{"name":"References",		"href": "?section=webhosting&page=webref"},
					{"name":"How-to",			"href": "?section=webhosting&page=webhow-to"}
					]
	},



	<?php
	if ( isset($_SESSION['group']) && substr_count($_SESSION['group'],"Admin") == 1 )
		{
		?>
				{"name": "Tools",   "href": "?section=admin&page=AccountManTools",   "file": "AccountManTools",
					"submenu": [
								{"name":"phpMyAdmin",	"href": "?section=special&page=downformaintenance"},
								{"name":"Qmail Admin",	"href": "?iframe=https://admin.jppeach.net/qmail/qmailadmin"},
								{"name":"Virtual Domain Administrator",	"href": "?section=special&page=downformaintenance"},
								]
				},
				{"name":"Wiki",   "href": "?section=admin&page=wiki",   "file": "wiki",
					"submenu": [
								{"name":"Wiki Main Page", "href": "?section=special&page=downformaintenance"},
								]
				},

	<?php

		}




		if (  isset($_SESSION['group']) && ( substr_count($_SESSION['group'],"Admin") == 1 ||  substr_count($_SESSION['group'],"Concordia") == 1 )    )
		{
		?>

	{"name":"Speak Easy",   "href": "?section=admin&page=speakEasy",   "file": "speakEasy",
		"submenu": [
				{"name":"Speak Easy Managed Services",	"href": "?iframe=http://www.speakeasy.net/service/ms/"},
				{"name":"Speak Easy Management",  "href": "?iframe=https://www.speakeasy.net/myspeak/index.mpl"},
				{"name":"Support",	"href": "?iframe=http://support.netfire.com/"},
					]
	},

<?php }


	if (    isset($_SESSION['group']) 				  &&
			(substr_count($_SESSION['group'],"Admin")    == 1 || substr_count($_SESSION['group'],"Concordia") == 1 || substr_count($_SESSION['group'],"Users")    == 1)
	   )
	{
	?>
	{"name":"Mail",   "href": "?section=admin&page=Mail",   "file": "Mail",
		"submenu": [
				{"name":"Horde",  "href": "?iframe=http://webmail.jppeach.net/horde/login.php"},
				{"name":"SquirrelMail",	"href": "?section=special&page=downformaintenance"},
				{"name":"RoundCube WebMail",	"href": "?iframe=http://roundcube.jppeach.net/"},


	<?php
		if (isset($_SESSION['group']) && (substr_count($_SESSION['group'],"Admin") == 1 ||  substr_count($_SESSION['group'],"Concordia") == 1 ))
		{
	?>
			{"name":"Qmail Admin",	"href": "?section=special&page=downformaintenance"},
			{"name":"Virtual Qmail Domain Administrator", "href": "?section=special&page=downformaintenance"},
			{"name":"Qmail Mrtg Stats", "href": "?section=special&page=downformaintenance"},

	<?php } ?>
	]

	},

	<?php
	}
		if
		(
			isset($_SESSION['group']) &&
			(
				substr_count($_SESSION['group'],"Admin")    == 1 ||
				substr_count($_SESSION['group'],"Concordia") == 1
			)
		)
		{
	?>

	{"name":"System Info",	"href": "?section=admin&page=SystemInfo",   "file": "SystemInfo",
		"submenu": [
				{"name":"Domain Bandwidth",	"href": "?section=special&page=downformaintenance"},
				{"name":"Server Bandwidth graphs",	"href": "?section=special&page=downformaintenance"},
				{"name":"Enviroment Variables",	"href": "?section=special&page=downformaintenance"},
				{"name":"Isoqlog MTA Log Analyzer",	"href": "?section=special&page=downformaintenance"},
				{"name":"phpInfo",	"href": "?section=special&page=downformaintenance"},
				{"name":"Qmail Mrtg Stats",	"href": "?section=special&page=downformaintenance"},
				{"name":"SysWatch",	"href": "?section=special&page=downformaintenance"},
				{"name":"Webalizer - jppeach.com",	"href": "?section=special&page=downformaintenance"},
				{"name":"Apache Info",  "href": "?iframe=https://admin.jppeach.net/apache/server-info/"},
				{"name":"Apache Status",  "href": "?iframe=https://admin.jppeach.net/apache/server-status/"},
					]
	},



	{"name":"Misc",   "href": "?section=admin&page=Misc",   "file": "Misc",
		"submenu": [
					{"name":"DynDNS", "href": "?iframe=https://www.dyndns.com/account/services/hosts/jpbackup.homeip.net"},
					{"name":"EveryDNS", "href": "?iframe=http://www.everydns.com/index.php"},
					]
	},



	{"name":"Contact Info",   "href": "?section=admin&page=ContactInfo",   "file": "ContactInfo",
		"submenu": [],
	},

<?php } ?>
]

window.onload = function() {


	//This block determines which page the user is currently on
	var querry = window.location.search;
	var equalSign = querry.indexOf("=");
	if (equalSign == -1) { var page = "services"; }
	else {
		var ampersand = querry.indexOf("&");
		if (ampersand > 0) { var page = querry.substring(equalSign + 1, ampersand); }
		else { var page = querry.substr(equalSign + 1); }
		}
	if (page == "admin") {
		var equalSign = querry.lastIndexOf("=");
		page = querry.substr(equalSign + 1); }

	//document.write(page);

	var sidebar = document.createElement("div");
	sidebar.id = "Sidebar";
	document.body.appendChild(sidebar);

	var sideLinkList = document.createElement("ul");
	sideLinkList.id = "ul2"

	// MENU GENERATION CODE HERE

	for (var i = 0; i < menu.length; ++i) {
		var sideLink = document.createElement("li");

	    //li.setAttribute('class',"SideLink");
	    var newAttr = document.createAttribute("class");
		newAttr.nodeValue = "SideLink";
		sideLink.setAttributeNode(newAttr);

		var sideLinkElement = document.createElement("a");

		if (menu[i].submenu && page == menu[i].file) {
			var sideLinkImage = document.createElement("img");
			sideLinkImage.setAttribute('src',"images/arrowD.jpg");
			sideLinkImage.setAttribute('class',"downArrow");
			sideLinkElement.appendChild(sideLinkImage);
		}
		else {
			var sideLinkImage = document.createElement("img");
			sideLinkImage.setAttribute('src',"images/arrowR.jpg");
			sideLinkImage.setAttribute('class',"sidelinkimage");
			sideLinkElement.appendChild(sideLinkImage);
		}

		var sideLinkName = document.createTextNode(menu[i].name)
		sideLinkElement.href = menu[i].href;
		sideLinkElement.name = menu[i].name;

		sideLinkElement.appendChild(sideLinkName);
		sideLink.appendChild(sideLinkElement);

		// SUBMENU GOES HERE
		if (menu[i].submenu && page == menu[i].file) {
			var subLinkList = document.createElement('ul');
			// subLinkList.setAttribute("class","SubLink");

			var submenu = menu[i].submenu;
			for (var j = 0; j < submenu.length; ++j) {

					var subLink = document.createElement("li");

					var newAttr = document.createAttribute("class");
					newAttr.nodeValue = "SubLink";
					subLink.setAttributeNode(newAttr);

					var subLinkElement = document.createElement("a");

					// adding the sub_link.gif to the subLink
					var subLinkImage = document.createElement("img");
					subLinkImage.setAttribute('src',"images/nav/sub_link.gif");
					subLinkImage.setAttribute('class',"sublinkimage");
					subLinkElement.appendChild(subLinkImage);

					var subLinkName = document.createTextNode(submenu[j].name)
					subLinkElement.href = submenu[j].href;
					subLinkElement.appendChild(subLinkName);

					subLink.appendChild(subLinkElement);
					subLinkList.appendChild(subLink);
			}

			// adding extra space below sublinks
			var subLinkBreak = document.createElement("li");
			var brk = document.createElement("br");
			subLinkBreak.appendChild(brk);
			var AttrSub = document.createAttribute("class");
			AttrSub.nodeValue = "SubLink";
			subLinkBreak.setAttributeNode(AttrSub);
			subLinkList.appendChild(subLinkBreak);

			sideLink.appendChild(subLinkList);
		}

		sideLinkList.appendChild(sideLink);
	}


	sidebar.appendChild(sideLinkList);


}

</script>

